# Maintainer: Diego Sogari <diego.sogari@falker.com.br>

_realname=edd-dbg
_depname=edd-test_o_matic
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=0.2.1
depver=0.4.3
pkgrel=2
pkgdesc="C++ library of debugging tools for OS X and Windows (mingw-w64)"
arch=('any')
url="https://bitbucket.org/edd/dbg/wiki/Home"
license=('Boost Software License')
makedepends=("${MINGW_PACKAGE_PREFIX}-gcc" "${MINGW_PACKAGE_PREFIX}-cmake")
depends=("${MINGW_PACKAGE_PREFIX}-edd-fungo")
commit=4bf707ee0f03
depcommit=33d4c79fd263
source=("${_realname}-${pkgver}.tar.gz::https://bitbucket.org/edd/dbg/get/${pkgver}.tar.gz"
        "${_depname}-${depver}.tar.gz::https://bitbucket.org/edd/test_o_matic/get/${depver}.tar.gz"
        "${_realname}-${pkgver}-complement.zip"
        "${_realname}-${pkgver}.patch")
sha256sums=('3c683d92c5a5b0a005d54257178512188d32d1affb7533e175f829d34e2e8c2a'
            '1e843b8ca8e3875161070b93be7b068c684c140d41c22bd1e3e3086c7d36322b'
            '90c6d53e4e7c1fa9579d33612a6ef14b4e0ffc459a63b562f767b3a4735193e6'
            '65166a8c8316c56e4040a8d0fac0d11741e75f054618229036786a8cee074536')

prepare() {
  cd "${srcdir}/${_realname}-${commit}"
  patch -Np1 -i "../${_realname}-${pkgver}.patch"
  cp -rf ../${_depname}-${depcommit}/* tests/test_o_matic
}

build() {
  rm -rf "${srcdir}/build-${MINGW_CHOST}"
  mkdir "${srcdir}/build-${MINGW_CHOST}"
  cd "${srcdir}/build-${MINGW_CHOST}"

  MSYS2_ARG_CONV_EXCL="-DCMAKE_INSTALL_PREFIX=" \
  ${MINGW_PREFIX}/bin/cmake.exe \
    -G"MSYS Makefiles" \
    -DCMAKE_INSTALL_PREFIX=${MINGW_PREFIX} \
    "../${_realname}-${commit}"

  make
}

check() {
  cd "${srcdir}/build-${MINGW_CHOST}"
  make test
}

package() {
  cd "${srcdir}/build-${MINGW_CHOST}"
  make DESTDIR="${pkgdir}" install
}
